package com.yunkaweilai.android.view.home;

import android.app.Activity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.yunkaweilai.android.R;
import com.yunkaweilai.android.base.BaseApplication;
import com.yunkaweilai.android.model.AppRuleModel;
import com.yunkaweilai.android.model.CountMainBean;

import org.w3c.dom.Text;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 统计的第二个View
 */
public class CountSecondView extends AbsHeaderView<CountMainBean.DataBean.InfoBean>{

    private final AppRuleModel.DataBean.InfoBean appRuleModel;

    @BindView(R.id.tv_member_all)
    TextView tvMemberAll;//本店会员总数
    @BindView(R.id.tv_member_new)
    TextView tvMemberNew;//今日会员增加数
    @BindView(R.id.tv_member_manual)
    TextView tvManualMember;//手工增加会员数
    @BindView(R.id.tv_member_wechat)
    TextView tvWechatMember;//微信增加会员数
    @BindView(R.id.tv_member_yesterday)
    TextView tvYesterdayMember;//昨日增加会员数
    @BindView(R.id.tv_order_today)
    TextView tvOrderToday;//今日订单数
    @BindView(R.id.tv_order_cost)
    TextView tvOrderCost;//消费订单
    @BindView(R.id.tv_order_recharge)
    TextView tvOrderRecharge;//充值订单
    @BindView(R.id.tv_order_yesterday)
    TextView tvOrderYesterday;//昨日订单
    @BindView(R.id.tv_cost_today)
    TextView tvCostToday;//今日消费单数
    @BindView(R.id.tv_member_cost)
    TextView tvMemberCost;//会员消费单数
    @BindView(R.id.tv_other_cost)
    TextView tvOtherCost;//散客消费单数
    @BindView(R.id.tv_cost_yesterday)
    TextView tvCostYesterday;//昨日消费单数
    @BindView(R.id.tv_refund_today)
    TextView tvRefundToday;//今日退款金额
    @BindView(R.id.tv_refund_count)
    TextView tvRefundCount;//退款笔数
    @BindView(R.id.tv_refund_yesterday)
    TextView tvRefundYesterday;//昨日退款金额
    @BindView(R.id.tv_refund_count_yesterday)
    TextView tvRefundCountYesterday;//昨日退款笔数


    public CountSecondView(Activity activity) {
        super(activity);
        appRuleModel = BaseApplication.getAppRuleModel();
    }

    @Override
    protected void getView(CountMainBean.DataBean.InfoBean infoBean, ListView listView) {
        View view = mInflate.inflate(R.layout.second_count_layout, listView, false);
        ButterKnife.bind(this, view);
        listView.addHeaderView(view);
        initView(infoBean);
    }

    private void initView(CountMainBean.DataBean.InfoBean infoBean) {
        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("3")){
            tvMemberAll.setText("本店会员总数:"+infoBean.getMember_count());
            tvMemberNew.setText("今日会员新增数:"+infoBean.getToday_member_count());
            tvManualMember.setText("手工新增:"+infoBean.getToday_member_pc_count());
            tvWechatMember.setText("微信招募:"+infoBean.getToday_member_wechat_count());
            tvYesterdayMember.setText("昨日新增:"+infoBean.getYesterday_member_count());
            tvOrderToday.setText("今日订单数:"+infoBean.getToday_z_order_count());
            tvOrderCost.setText("消费订单:"+infoBean.getToday_order_count());
            tvOrderRecharge.setText("充值订单:"+infoBean.getToday_recharge_order_count());
            tvOrderYesterday.setText("昨日订单:"+infoBean.getYesterday_z_order_count());
            tvCostToday.setText("今日消费单数:"+infoBean.getToday_order_count());
            tvMemberCost.setText("会员单数:"+infoBean.getToday_member_order_count());
            tvOtherCost.setText("散客单数:"+infoBean.getToday_unmember_order_count());
            tvCostYesterday.setText("昨日消费单数:"+infoBean.getYesterday_z_consume_order_count());
            tvRefundToday.setText("今日退款金额:"+infoBean.getToday_refund_order_price());
            tvRefundCount.setText("退款笔数:"+infoBean.getToday_refund_order_count());
            tvRefundYesterday.setText("昨日退款金额:"+infoBean.getYesterday_refund_order_price());
            tvRefundCountYesterday.setText("退款笔数:"+infoBean.getYesterday_refund_order_count());
        }
        else{
            tvMemberAll.setText("本店会员总数:"+"--");
            tvMemberNew.setText("今日会员新增数:"+"--");
            tvManualMember.setText("手工新增:"+"--");
            tvWechatMember.setText("微信招募:"+"--");
            tvYesterdayMember.setText("昨日新增:"+"--");
            tvOrderToday.setText("今日订单数:"+"--");
            tvOrderCost.setText("消费订单:"+"--");
            tvOrderRecharge.setText("充值订单:"+"--");
            tvOrderYesterday.setText("昨日订单:"+"--");
            tvCostToday.setText("今日消费单数:"+"--");
            tvMemberCost.setText("会员单数:"+"--");
            tvOtherCost.setText("散客单数:"+"--");
            tvCostYesterday.setText("昨日消费单数:"+"--");
            tvRefundToday.setText("今日退款金额:"+"--");
            tvRefundCount.setText("退款笔数:"+"--");
            tvRefundYesterday.setText("昨日退款金额:"+"--");
            tvRefundCountYesterday.setText("退款笔数:"+"--");
        }
    }

    public void refresh(CountMainBean.DataBean.InfoBean infoBean){
        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("3")){
            tvMemberAll.setText("本店会员总数:"+infoBean.getMember_count());
            tvMemberNew.setText("今日会员新增数:"+infoBean.getToday_member_count());
            tvManualMember.setText("手工新增:"+infoBean.getToday_member_pc_count());
            tvWechatMember.setText("微信招募:"+infoBean.getToday_member_wechat_count());
            tvYesterdayMember.setText("昨日新增:"+infoBean.getYesterday_member_count());
            tvOrderToday.setText("今日订单数:"+infoBean.getToday_z_order_count());
            tvOrderCost.setText("消费订单:"+infoBean.getToday_order_count());
            tvOrderRecharge.setText("充值订单:"+infoBean.getToday_recharge_order_count());
            tvOrderYesterday.setText("昨日订单:"+infoBean.getYesterday_z_order_count());
            tvCostToday.setText("今日消费单数:"+infoBean.getToday_order_count());
            tvMemberCost.setText("会员单数:"+infoBean.getToday_member_order_count());
            tvOtherCost.setText("散客单数:"+infoBean.getToday_unmember_order_count());
            tvCostYesterday.setText("昨日消费单数:"+infoBean.getYesterday_z_consume_order_count());
            tvRefundToday.setText("今日退款金额:"+infoBean.getToday_refund_order_price());
            tvRefundCount.setText("退款笔数:"+infoBean.getToday_refund_order_count());
            tvRefundYesterday.setText("昨日退款金额:"+infoBean.getYesterday_refund_order_price());
            tvRefundCountYesterday.setText("退款笔数:"+infoBean.getYesterday_refund_order_count());
        }
        else{
            tvMemberAll.setText("本店会员总数:"+"--");
            tvMemberNew.setText("今日会员新增数:"+"--");
            tvManualMember.setText("手工新增:"+"--");
            tvWechatMember.setText("微信招募:"+"--");
            tvYesterdayMember.setText("昨日新增:"+"--");
            tvOrderToday.setText("今日订单数:"+"--");
            tvOrderCost.setText("消费订单:"+"--");
            tvOrderRecharge.setText("充值订单:"+"--");
            tvOrderYesterday.setText("昨日订单:"+"--");
            tvCostToday.setText("今日消费单数:"+"--");
            tvMemberCost.setText("会员单数:"+"--");
            tvOtherCost.setText("散客单数:"+"--");
            tvCostYesterday.setText("昨日消费单数:"+"--");
            tvRefundToday.setText("今日退款金额:"+"--");
            tvRefundCount.setText("退款笔数:"+"--");
            tvRefundYesterday.setText("昨日退款金额:"+"--");
            tvRefundCountYesterday.setText("退款笔数:"+"--");
        }
    }
}
